/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: Mem.c
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: Mem
*
*******************************************************************************/

/** HEADER FILES **/
#include "Mem.h"


/** MACRO DEFINITION **/


/** TYPEDEF DEFINITION **/


/** LOCAL DATA DECLARATION **/


/** GLOBAL DATA DECLARATION **/


/** LOCAL FUNCTION DECLARATION **/


/** GLOBAL FUNCTION DECLARATION **/
void Mem_GetVersionInfo(
    Std_VersionInfoType* versionInfo
);


Std_ReturnType Mem_Read(
    Mem_InstanceIdType instanceId,
    Mem_AddressType sourceAddress,
    Mem_DataType* destinationDataPtr,
    Mem_LengthType length
);


Std_ReturnType Mem_Write(
    Mem_InstanceIdType instanceId,
    Mem_AddressType targetAddress,
    const Mem_DataType* sourceDataPtr,
    Mem_LengthType length
);


/** LOCAL DATA **/


/** GLOBAL DATA **/


/** LOCAL FUNCTION **/


/** GLOBAL FUNCTION **/

/*******************************************************************************
* -Name            Mem_GetVersionInfo
* -Brief           Returns the version information of this module 
* -Details         None
* -Param[out]      versioninfo: Pointer to the version information of this module
* -Return          None          
*******************************************************************************/
void Mem_GetVersionInfo(
    Std_VersionInfoType* versionInfo
)
{
    versionInfo->vendorID = (uint16)YSAR_VENDOR_ID;
    versionInfo->moduleID = (uint8)MEM_MODULE_ID;
    versionInfo->sw_major_version = (uint8)MEM_SW_MAJOR_VERSION;
    versionInfo->sw_minor_version = (uint8)MEM_SW_MINOR_VERSION;
    versionInfo->sw_patch_version = (uint8)MEM_SW_PATCH_VERSION;
}

/*******************************************************************************
* -Name            Mem_Init
* -Brief           Initialization function - initializes all variables and sets the module state to initialized 
* -Details         None
* -Param[in]       configPtr: Pointer to the configuration data structure - since Mem driver is a precompile module this parameter is typically not used
* -Return          None          
*******************************************************************************/
void Mem_Init(
    const Mem_ConfigType* configPtr
)
{
    
}

/*******************************************************************************
* -Name            Mem_Read
* -Brief           Triggers a read job to copy the from the source address into the referenced destination data buffer 
* -Details         None
* -Param[in]       instanceId: ID of the related memory driver instance
* -Param[in]       sourceAddress: Physical address to read data from
* -Param[in]       length: Read length in bytes
* -Param[out]      destinationDataPtr: Destination memory pointer to store the read data
* -Return          E_OK: The requested job has been accepted by the module
                   E_NOT_OK: The requested job has not been accepted by the module
                   E_MEM_SERVICE_NOT_AVAIL: The service function is not implemented
*******************************************************************************/
Std_ReturnType Mem_Read(
    Mem_InstanceIdType instanceId,
    Mem_AddressType sourceAddress,
    Mem_DataType* destinationDataPtr,
    Mem_LengthType length
)
{
    CDD_24C02_MemRead(instanceId, sourceAddress, destinationDataPtr, length);
}

/*******************************************************************************
* -Name            Mem_Write
* -Brief           Triggers a write job to store the passed data to the provided address area with given address and length 
* -Details         None
* -Param[in]       instanceId: ID of the related memory driver instance
* -Param[in]       targetAddress: Physical write address (aligned to page size)
* -Param[in]       sourceDataPtr: Source data pointer (aligned to page size)
* -Param[in]       length: Write length in bytes (aligned to page size)
* -Return          E_OK: The requested job has been accepted by the module
                   E_NOT_OK: The requested job has not been accepted by the module
                   E_MEM_SERVICE_NOT_AVAIL: The service function is not implemented
*******************************************************************************/
Std_ReturnType Mem_Write(
    Mem_InstanceIdType instanceId,
    Mem_AddressType targetAddress,
    const Mem_DataType* sourceDataPtr,
    Mem_LengthType length
)
{
    CDD_24C02_MemWrite(instanceId, targetAddress, sourceDataPtr, length);
}


